<template>
	<view class="page-fill">
		<!-- 搜索层 -->
		<search @search="searchbook"></search>
		<!-- 分类层 -->
		<view class="c_text"> 分类 </view>
		<view class="cat_wrap">
			<view class="cat_item" @tap="gotocindex(index)" v-for="(item,index) in cclist" :key="index">
				<view class="cat_item_title">{{item.category}}</view>
				<view class="cat_item_num">{{item.count}}本</view>
			</view>
		</view>
		<!-- 说明层 -->
		<view class="notewrap">
			<view class="note">本站小说来源于免费小说网站，本站不存储任何小说相关内容。</view>
			<view class="note">&copy;版权所有 支持正版</view>
		</view>
	</view>
</template>

<script>
	import search from '@/components/search/search.vue'

	export default {
		data() {
			return {
				cclist:[{"category":"玄幻魔法","count":37170},
				{"category":"武侠修真","count":9630},
				{"category":"都市言情","count":25860},
				{"category":"历史军事","count":7020},
				{"category":"侦探推理","count":90},
				{"category":"网友动漫","count":7470},
				{"category":"科幻灵异","count":9360}]
			}
		},
		components: {
			search
		},
		onLoad() {
			this.getcategorycount();
		},
		methods: {
			searchbook(e) {
				uni.navigateTo({
					url:'../search/search?searchkey='+e
				});
			},
			getcategorycount(){
				var me = this;
				var url = me.websiteUrl + "getcategorycount";
				me.webhttp(url,{}).then(res=>{
					console.log(res);
					if(res.code == 200){
						me.cclist = res.cclist;
					}
				})
			},
			gotocindex(cindex) {
				var me = this;
				//console.log(me.cclist[0].category);
				var category = me.cclist[cindex].category;
				
				uni.navigateTo({
					url: '../categoryindex/categoryindex?category='+category
				});
			}
		}
	}
</script>

<style>
	@import url("index.css");
</style>
